﻿@using OBUCare.Core.Models
@using OBUCare.Web.Infrastructure
@using OBUCare.Core.Common
@using OBUCare.Core.DataAccess
@using OBUCare.Core.BL
@model View_RepariOrders
@{
    Layout = "";
    var Faults = ViewBag.Faults as IList<REPAIR_ORDER_FAULT>;

    string remark = "";
}
@Scripts.Render("~/bundles/Common")
<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
<div>
    <p>
        <input type="button" onclick="onPrint()" value="打印" />
        <input type="button" onclick="CloseWindow()" value="关闭" />
    </p>
</div>
<div id="divPrint" style="width: 100%">
    <table id="tbOrder">
        <tr style="height: 60px;">
            <td style="width: 15%; text-align: left">
                <!--受理营业厅：-->
            </td>
            <td style="width: 35%; text-align: left;">
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;@Model.AGENT_NAME
            </td>
            <td style="width: 30%; text-align: left">
                <!--流水单号：-->
            </td>
            <td style="width: 20%; text-align: left;">@Model.REPAIR_ORDER_NO
            </td>
        </tr>
        <tr style="height: 110px">
            <td style="text-align: left">
                <!--基本信息：-->
            </td>
            <td colspan="3" style="text-align: left">
                <table width="100%">
                    <tr>
                        <td style="width:50%">
                            品牌:@Model.SUPPLIER_ShortName &nbsp;&nbsp;&nbsp;

                            型号:@Model.SPEC_NAME 
                        </td>
                        <td style="width:50%">
                            车号:@Model.VEHICLE_PLATE_NO
                        </td>
                    </tr>
                    <tr style="height: 1px">
                        <td colspan="2">
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            SN:@Model.OBU_NO &nbsp;&nbsp;&nbsp;
                        </td>
                        <td rowspan="2">
                            所有人:@Model.OWNER_NAME
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr style="height: 20px">
            <td style="text-align: left">
                &nbsp;
            </td>
        </tr>
        <tr style="height: 100px">
            <td>
                <!-- 故障描述-->
            </td>
            <td colspan="2">
                @for (int j = 0; j < Faults.Count; j++)
                {
                    var faultRemark = Faults[j].FAULT_TYPE.ToString();
                    var dictValue = (from i in new OBU_CAREContext().DICT_TYPE_VALUE.Include("DICT_TYPE")
                                     where i.DICT_TYPE.TYPE_CODE == "FaultType" && i.DICT_CODE.Equals(faultRemark)
                                     select i).FirstOrDefault();

                    string remarkone = dictValue.DICT_TITLE;
                    if (Faults[j].FAULT_TYPE == 6)
                    {
                        remarkone = Faults[j].REMARK;
                    }
                    if (j % 2 == 1)
                    {
                    @remarkone @:&nbsp;&nbsp;&nbsp;<br/>
                }
                    else
                    {
                    @remarkone @:&nbsp;&nbsp;&nbsp;
                                                                                                                                                                                                }
                }
            </td>
            @*            <td>
                <!--外观检测：-->
            </td>*@
            <td style="text-align: center;">
                @if (!Model.FACE_STATUS) // "数据库中0为完整，1为故障"
                {
                    @:完整
                }
                else
                {
                    @:损坏
                                                                                                                                                                                                 }
            </td>
        </tr>
        <tr style="height: 90px">
            <td>
                <!--送修标签维修类型,双方确认：乙方送修的电子标签属于下列哪种情况？-->
            </td>
            <td>
                @if (Model.REPAIR_TYPE != null)
                {
                    string repair_type = "";
                    if (Model.REPAIR_TYPE != 5)
                    {
                        var repair_type_model = (from i in new OBU_CAREContext().REPAIR_TYPE
                                                 where i.ID == Model.REPAIR_TYPE
                                                 select i).FirstOrDefault();
                        repair_type = repair_type_model.TITLE;
                    }
                    else
                    {
                        repair_type = Model.REPAIRED_COMMENT;
                    }
                    @repair_type;
                }
            </td>
            <td>
                @*可接受的维修费用*@
            </td>
            <td style="text-align: center;">@Model.MAX_PRICE
            </td>
        </tr>
        <tr style="height: 90px">
            <td>
                <!--是否需要速通公司提供备用标签使用：-->
            </td>
            <td colspan="2">
                @if (Model.SPARE_OBU_NO == null && Model.SPARE_OBU_PRICE == null && Model.SPARE_OBU_ISSUE_DATE == null)
                {
                    @:否&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                }
                else
                {
                    @:是
                                                                                                                                                                                                                                                                }
                &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                @if (!Model.SPARE_OBU_NO.IsNullOrEmpty())
                {
                    @:SN: @Model.SPARE_OBU_NO
                                                                                                                                                                }
            </td>
            @*            <td>
                <!--送修人的联系方式-->
            </td>*@
            <td style="text-align: center;">
                &nbsp; &nbsp; &nbsp;@Model.MOBILE_TEL_NO </br> &nbsp;</br> &nbsp; &nbsp; &nbsp;@Model.TEL_NO
            </td>
        </tr>
        <tr style="height: 100px">
            <td>
                <!--营业厅受理人-->
            </td>
            <td>@Model.CreatedByName
            </td>
            <td>
                <!--受理日期-->
            </td>
            <td style="text-align: center;">@Model.REPORT_DATE.ToShortDateString()
            </td>
        </tr>
    </table>
</div>
<script>
    function onPrint() {
        printpage('divPrint');
        //window.location.href = '@ViewBag.URL';
        // document.getElementById("dv1").setAttribute("style", "display:none");
    }
</script>
